<?php
use yii\helpers\Html;
use yii\helpers\Url;
use app_supplier\assets\SuppAssets;
use yii\helpers\HtmlPurifier;

SuppAssets::addScript($this, '@web/js/scroll.js');
SuppAssets::addArrayCss($this, [
    '@web/css/main-index.css',
]);
?>
<div class="box">
    <div class="heading">
        <h1><img src="<?=Url::to('@web/images/')?>home.png" alt="">系统首页</h1>

        <img src="<?=Url::to('@web/images/')?>jichuban.png" style="height:25px; margin:10px 0 0 30px;">

        <img src="<?=Url::to('@web/images/')?>gaojiban.png" style="height:25px; margin:10px 0 0 30px;">

    </div>
    <div class="content">
        <div class="overview">
            <div class="dashboard-heading">服务项目</div>
            <style>

            </style>
            <div class="dashboard-content dashboard-menu">

                <div>
                    <ul id="menu-select">
                        <li>
                            <a href="/store/demo/order/wash" data-id="001">
                                <img src="<?=Url::to('@web/images/menu/001-a.png')?>">
                            </a>
                        </li>
                        <li><a href="/store/demo/order/maintenance?category=1" data-id="002"><img
                                    src="<?=Url::to('@web/images/menu/')?>023-a.png"></a></li>
                        <li><a href="/store/demo/order/maintenance?category=2" data-id="003"><img
                                    src="<?=Url::to('@web/images/menu/')?>022-a.png"></a></li>
                        <li><a href="/store/demo/order/maintenance?category=3" data-id="004"><img
                                    src="<?=Url::to('@web/images/menu/')?>004-a.png"></a></li>
                        <li><a href="/store/demo/order/maintenance?category=4" data-id="005"><img
                                    src="<?=Url::to('@web/images/menu/')?>005-a.png"></a></li>
                        <li><a href="/store/demo/order/maintenance?category=5" data-id="006"><img
                                    src="<?=Url::to('@web/images/menu/')?>006-a.png"></a></li>
                        <li><a href="/store/demo/order/maintenance?category=6" data-id="007"><img
                                    src="<?=Url::to('@web/images/menu/')?>007-a.png"></a></li>
                        <li><a href="/store/demo/order/maintenance?category=8" data-id="008"><img
                                    src="<?=Url::to('@web/images/menu/')?>008-a.png"></a></li>
                        <li><a href="/store/demo/order/maintenance?category=9" data-id="009"><img
                                    src="<?=Url::to('@web/images/menu/')?>009-a.png"></a></li>
                        <li><a href="/store/demo/card/create" data-id="010"><img
                                    src="<?=Url::to('@web/images/menu/')?>010-a.png"></a></li>
                    </ul>
                </div>
            </div>
            <script>
                var menuApp = {
                    init: function () {
                        var menuSelect = [];
                        var menuDefault = [
                            {
                                icon: '020',
                                target: true,
                                name: '洗车业务',
                                route: 'affiliate/order/wash',
                                'link': "/store/demo/order/wash"
                            },
                            {
                                icon: '021',
                                target: true,
                                name: '发动机保养',
                                route: 'affiliate/order/maintenance',
                                'link': "/store/demo/order/maintenance?category=1"
                            },
                            {
                                icon: '014',
                                target: true,
                                name: '车辆养护',
                                route: 'affiliate/order/maintenance',
                                'link': "/store/demo/order/maintenance?category=2"
                            },
                            {
                                icon: '021',
                                target: true,
                                name: '轮胎业务',
                                route: 'affiliate/order/maintenance',
                                'link': "/store/demo/order/maintenance?category=3"
                            },
                            {
                                icon: '021',
                                target: true,
                                name: '代办救援',
                                route: 'affiliate/order/maintenance',
                                'link': "/store/demo/order/maintenance?category=4"
                            },
                            {
                                icon: '021',
                                target: true,
                                name: '车辆美容',
                                route: 'affiliate/order/maintenance',
                                'link': "/store/demo/order/maintenance?category=5"
                            },
                            {
                                icon: '021',
                                target: true,
                                name: '钣金喷漆',
                                route: 'affiliate/order/maintenance',
                                'link': "/store/demo/order/maintenance?category=6"
                            },
                            {
                                icon: '021',
                                target: true,
                                name: '更换配件',
                                route: 'affiliate/order/maintenance',
                                'link': "/store/demo/order/maintenance?category=8"
                            },
                            {
                                icon: '021',
                                target: true,
                                name: '维修检查',
                                route: 'affiliate/order/maintenance',
                                'link': "/store/demo/order/maintenance?category=9"
                            },
                            {
                                icon: '021',
                                target: false,
                                name: '会员中心',
                                route: 'affiliate/card/create',
                                'link': "/store/demo/card/create"
                            }
                        ]
                        if (menuSelect.length == 0) {
                            this.load(menuDefault);
                        }
                        $("#menu-select li a").mouseover(function () {
                            var icon = $(this).attr("data-id");
                            var hoverSrc = "<?=Url::to('@web/images/menu/')?>" + icon + "-b.png";
                            $(this).find('img').attr("src", hoverSrc);
                        }).mouseout(function () {
                            var icon = $(this).attr("data-id");
                            var src = "<?=Url::to('@web/images/menu/')?>" + icon + "-a.png";
                            $(this).find('img').attr("src", src);
                        });
                    }, load: function (data) {
                        var tmp = '';
                        $(data).each(function (i, item) {
                            tmp += "<li><a href='" + item.link + "' data-id=\"" + item.icon + "\"><img src=\"<?=Url::to('@web/images/menu/')?>" + item.icon + "-a.png\"></a> </li>"
                        });
                        $("#menu-select").html(tmp);
                    }
                }
                menuApp.init();
            </script>
        </div>
        <div class="statistic">
            <div class="dashboard-heading">配件求购
                <span style="float:right;">
                    <!--a target="_blank" style="border-radius:3px;font-size:12px;padding:3px 5px 3px 5px;background:#c8a397; color:white" onclick="prompt()">短信&nbsp;&nbsp;169&nbsp;</a-->&nbsp;
                    <a href="<?=Url::to(['purchase/order'])?>" style="border-radius:3px;font-size:12px;padding:3px 5px 3px 5px;background:blue; color:white">消耗&nbsp;&nbsp;<?=$num['pur_total']?>&nbsp;</a>&nbsp;
                    <!--a href="/store/demo/remind?id=20" style="border-radius:3px;font-size:12px;padding:3px 5px 3px 5px;background:pink; color:white">保险&nbsp;&nbsp;1&nbsp;</a-->&nbsp;
                    <a href="<?=Url::to(['purchase/index'])?>" style="border-radius:3px;font-size:12px;padding:3px 5px 3px 5px;background:limegreen; color:white">商机&nbsp;<?=$num['cost_num']?>&nbsp;</a>
                </span>
            </div>
            <div class="dashboard-content" style="height:216px;">
                <table class="list my-list" id="list-table" style="margin-top:6px; margin-bottom:17px;">
                    <thead>
                    <tr>
                        <th class="center" width="70">区域</th>
                        <th class="center" width="120">发布时间</th>
                        <th class="center" width="80">需求时间</th>
                        <th class="center" >适配车型</th>
                        <th class="center" >配件型号</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php if (isset($items) && !empty($items) && is_array($items)):?>
                        <?php foreach ($items as $key=>$row):?>
                            <?php if (($key+1)%2==0):?>
                                <tr class="my-list-tr">
                                    <td class="center"><?=$row['address_city']?></td>
                                    <td class="center"><?=$row['create_time']?></td>
                                    <td class="center"><?=$row['demand_time']?></td>
                                    <td class="center"><?=$row['car_type']?></td>
                                    <td class="center"><?=$row['material_version']?></td>
                                </tr>
                            <?php else:?>
                                <tr>
                                    <td class="center"><?=$row['address_city']?></td>
                                    <td class="center"><?=$row['create_time']?></td>
                                    <td class="center"><?=$row['demand_time']?></td>
                                    <td class="center"><?=$row['car_type']?></td>
                                    <td class="center"><?=$row['material_version']?></td>
                                </tr>
                            <?php endif;?>

                        <?php endforeach;?>
                    <?php endif;?>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="todo">
            <div id="tabs" class="dashboard-heading">
                待处理订单
            </div>
            <div id="tab-todo">
                <table class="list">
                    <thead>
                    <tr>
                        <td class="center" width="120">订单编号</td>
                        <td class="center" width="100">状 态</td>
                        <td class="center" width="150">订单金额</td>
                        <td class="center">门 店</td>
                        <td class="center" width="150">联系人</td>
                        <td class="center">联系手机</td>
                        <td class="center">下单时间</td>
                        <td class="center">备注</td>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                        <td class="center">
                            <a  href="/store/demo/order/operation?order_number=M281702100003">P281702100003</a>
                        </td>
                        <td class="center">运送中</td>
                        <td class="center">￥250.00</td>
                        <td class="center">样板店</td>
                        <td class="center">包雷</td>
                        <td class="center">13980558350</td>
                        <td class="center">2017-01-03</td>
                        <td class="center">请尽快运送</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script>
   ;
    $(function(){
//        $("#list-table").myScroll({
//            speed:40, //数值越大，速度越慢
//            rowHeight:68 //li的高度
//        });

        $(function(){
            var _wrap=$('#list-table>tbody');
            var _interval=2000;//定义滚动间隙时间
            var _moving;//需要清除的动画
            _wrap.hover(function(){
                clearInterval(_moving);//当鼠标在滚动区域中时,停止滚动
            },function(){
                _moving=setInterval(function(){
                    var _field=_wrap.find('tr:first');//此变量不可放置于函数起始处,li:first取值是变化的
                    var _h=_field.height();//取得每次滚动高度(多行滚动情况下,此变量不可置于开始处,否则会有间隔时长延时)
                    _wrap.animate({marginTop:-_h+'px'}, 600,function(){//通过取负margin值,隐藏第一行
                        if (_field.attr('class')=='my-list-tr') {
                            _field.removeClass('my-list-tr');
                        } else {
                            _field.addClass('my-list-tr');
                        }
                        _field.css('marginTop',0).appendTo(_wrap);//隐藏后,将该行的margin值置零,并插入到最后,实现无缝滚动
                        _wrap.css('marginTop',0);
                    })
                },_interval);//滚动间隔时间取决于_interval
            }).trigger('mouseleave');//函数载入时,模拟执行mouseleave,即自动滚动
        });
    });
</script>